<%@page import="cn.edu.pku.wxlib.shelf.model.*"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<%@ include file="/commons/taglibs.jsp"%>

<rapid:override name="head">
	<title>Shelf维护</title>

	<script src="${ctx}/scripts/rest.js"></script>
	<link href="<c:url value="/widgets/simpletable/simpletable.css"/>"
		type="text/css" rel="stylesheet">
	<script type="text/javascript"
		src="<c:url value="/widgets/simpletable/simpletable.js"/>"></script>

	<script type="text/javascript">
		$(document).ready(function() {
			window.simpleTable = new SimpleTable('queryForm',${page.thisPageNumber},${page.pageSize},'${pageRequest.sortColumns}');
		});
	</script>
</rapid:override>

<rapid:override name="content">
	<form id="queryForm" name="queryForm" method="get"
		style="display: inline;">
		<div class="search">
			<div class="form-group inline icon">
				<i class="icon-list"></i> <input placeholder="输入书架编号"
					value="${query.shelfNumber}" id="shelfNumber" name="shelfNumber"
					maxlength="6" class="form-field col-1-5" /> <br />
			</div>
			<div class="form-group inline icon">
				<i class="icon-list"></i> <input placeholder="输入书架名"
					value="${query.shelfName}" id="shelfName" name="shelfName"
					maxlength="32" class="form-field col-1-5" /> <br />
			</div>
			<%-- <div class="form-group inline icon">
				<i class="icon-list"></i> <input placeholder="输入价格"
					value="${query.price}" id="price" name="price" maxlength="22"
					class="form-field col-1" /> <br />
			</div> --%>
			<div class="form-group inline icon">
				<i class="icon-calendar"></i> <input placeholder="创建时间开始"
					type="text" value="${query.createTimeBegin}" id="createTimeBegin"
					name="createTimeBegin" class="form-field col-1-5" />
			</div>
			<strong>至</strong>
			<div class="form-group inline icon">
				<i class="icon-calendar"></i> <input placeholder="创建时间结束"
					type="text" value="${query.createTimeEnd}" id="createTimeEnd"
					name="createTimeEnd" class="form-field col-1-5" /> <br />
			</div>

			<div class="form-group inline">
				<select id="state" name="state" class="form-field col-1-5">
					<option value="">用户状态</option>
					<option value="0"
						<c:if test="${query.state==0}">selected="selected"</c:if>>禁用</option>
					<option value="1"
						<c:if test="${query.state==1}">selected="selected"</c:if>>启用</option>
				</select>
			</div>
			<div class="form-group inline icon search-btn"
				onclick="$('#queryForm').submit();" title="查询">
				<i class="icon-search"></i>
			</div>
		</div>
	</form>


	<!--<button type="button" class="btn btn-default" onclick="getReferenceForm(this).action='${ctx}/shelf'">查询</button>-->
	<div class="handleControl">
		<button type="button" class="btn btn-primary"
			onclick="window.location = '${ctx}/shelf/new'">新增</button>
		<button type="button" class="btn btn-default"
			onclick="doRestBatchDelete('${ctx}/shelf','items',document.forms.queryForm)">删除</button>

	</div>

	<div class="gridTable">
		<table width="100%" border="0" cellspacing="0"
			class="table text-center">
			<thead>
				<tr>
					<th style="width: 1px;"><input type="checkbox"
						onclick="setAllCheckboxState('items',this.checked)"></th>
					<th sortColumn="shelfNumber">书架编号</th>
					<th sortColumn="shelfName">书架名</th>
					<th sortColumn="price">价格</th>
					<th sortColumn="createTime">创建时间</th>
					<th sortColumn="state">状态</th>
					<th style="white-space: nowrap;">操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${page.result}" var="item" varStatus="status">
					<tr>
						<td><input type="checkbox" name="items"
							value="${item.shelfId}"></td>
						<td><c:out value='${item.shelfNumber}' />&nbsp;</td>
						<td><c:out value='${item.shelfName}' />&nbsp;</td>
						<td><c:out value='${item.price}' />&nbsp;</td>
						<td><c:out value='${item.createTimeString}' />&nbsp;</td>
						<td><c:out value='${item.state}' />&nbsp;</td>
						<td><a href="${ctx}/shelf/${item.shelfId}" class="operation">查看</a>&nbsp;&nbsp;
							<a href="${ctx}/shelf/${item.shelfId}/edit" class="operation">修改</a>&nbsp;&nbsp;
							<a href="${ctx}/shelf/${item.shelfId}"
							onclick="doRestDelete(this,'你确认删除?');return false;"
							class="operation">删除</a></td>
					</tr>

				</c:forEach>
			</tbody>
		</table>

		<simpletable:pageToolbar page="${page}">
		</simpletable:pageToolbar>

	</div>
</rapid:override>
<rapid:override name="script">
	<script>
	var picker1 = new Pikaday(
		    {
		        field: document.getElementById('createTimeBegin'),
		        firstDay: 1,
		        minDate: new Date('1900-01-01'),
		        maxDate: new Date('2020-12-31'),
		        yearRange: [1900,2020]
		    });
		    
	var picker2 = new Pikaday(
		    {
		        field: document.getElementById('createTimeEnd'),
		        firstDay: 1,
		        minDate: new Date('1900-01-01'),
		        maxDate: new Date('2020-12-31'),
		        yearRange: [1900,2020]
		    });
	
	/*function setAllCheckboxState(name,state) {
		var elms = document.getElementsByName(name);
		for(var i = 0; i < elms.length; i++) {
			elms[i].checked = state;
		}
	}
	$("[name='state_checkBox']").bootstrapSwitch('onText','启用');
	$("[name='state_checkBox']").bootstrapSwitch('offText','禁用');
	$("input[type=checkbox][name='state_checkBox']").on('switchChange.bootstrapSwitch', function (event, state) {
		var adminId = this.value;		
		if ($(this).is(":focus") == false) 
			return;
// 		else
// 			document.getElementById("tel").value=adminId;
		if (state == true)
		{
			$(this).blur();
			if(confirm('确定执行启用操作？')){
				window.open("${ctx}/adminuser/"+adminId+"&1/changeState","_self");
			}
			else
				$(this).bootStrapSwitch('state', false);
		}
		if (state == false)
		{
			$(this).blur();
			if(confirm('确定执行禁用操作？')){
				window.open("${ctx}/adminuser/"+adminId+"&0/changeState","_self");
			}
			else
				$(this).bootstrapSwitch('state', true);
		}
	});*/
	
	</script>
</rapid:override>
<%@ include file="base.jsp"%>
